import Vue from "vue"
import VueRouter from "vue-router"


// 1、注入插件
Vue.use(VueRouter);

// 2、定义路由 注意拼写
const routes = [
    {
        path: '*',
        redirect: '/404'
    },
    {
        path: '/',
        // redirect: '/home',
        name: 'home',
        component: () => import('@/pages/Home'),
        meta:{
            title: '首页'
        }
    },
    // {
    //     path: '/home',
    //     component: () => import('@/pages/Home'),
    //     meta:{
    //         title: '首页'
    //     }
    // },
    {
        path: '/login',
        name: 'login',
        component: () => import('@/pages/Login'),
        meta:{
            title: '登录'
        }
    },
    {
        path: '/register',
        name: 'register',
        component: () => import('@/pages/Register'),
        meta:{
            title: '注册'
        }
    },
    {
        path: '/my-article',
        name: 'my-article',
        component: () => import('@/pages/MyArticle'),
        meta:{
            title: '我的文章'
        }
    },
    {
        path: '/dynamic',
        name: 'dynamic',
        component: () => import('@/pages/Dynamic'),
        meta:{
            title: '动态'
        }
    },
    {
        path: '/editor',
        name: 'editor',
        component: () => import('@/pages/Editor'),
        meta:{
            title: '编辑器'
        }
    },
    {
        path: '/editor-modify',
        name: 'editor-modify',
        component: () => import('@/pages/Editor'),
        meta:{
            title: '编辑器'
        }
    },
    {
        path: '/article',
        name: 'article',
        component: () => import('@/pages/Article'),
        // component: Article,
        meta:{
            title: ''
        }
    },
    {
        path: '/404',
        component: () => import('@/pages/404'),
        meta:{
            title: '找不到该页面'
        }
    },
    {
        path: '/user/:id',
        name: 'userinfo',
        component: () => import('@/pages/UserInfo'),
        meta: {
            title: '用户信息'
        }
    },
    {
        path: '/user-profile',
        name: 'userprofile',
        component: () => import('@/pages/SelfInfo'),
        meta: {
            title: '个人资料'
        }
    },
    {
        path: '/my-collect',
        name: 'my-collect',
        component: () => import('@/pages/MyCollect'),
        meta: {
            title: '我的收藏'
        }
    },
    {
        path: '/my-attention',
        name: 'my-attention',
        component: () => import('@/pages/MyAttention'),
        meta: {
            title: '我的关注'
        }
    },
    {
        path: '/back-stage',
        redirect: '/back-stage/article-manager'
    },
    {
        path: '/back-stage',
        name: 'back-stage',
        component: () => import('@/pages/BackStage'),
        meta: {
            title: '用户后台'
        },
        children: [
            {
                path: 'article-manager/',
                name: 'article-manager',
                component: () => import('@/pages/backstagepages/ArticleManager'),
                meta: {
                    title: '文章管理',
                }
            },
            {
                path: 'tag-manager',
                name: 'tag-manager',
                component: () => import('@/pages/backstagepages/TagsManager'),
                meta: {
                    title: '标签管理'
                }
            }
        ]
    }
]

// 3、创建router实例
const router = new VueRouter({
    routes,
    mode: 'history'
    // 改变路径的方式有两种: 1、URL的hash（地址栏后面自动会加上/#/）  2、HTML5的history
    // 默认情况下, 路径的改变使用的URL的hash.
})

// 4、导出router实例
export default router
